<template>
  <div>
    <el-row :gutter="12">
      <el-col :span="6" v-for="item in info" :key="item.id">
        <el-card shadow="hover">
          <div class="crad">
            <i
              class="iconfont"
              :class="item.icon"
              :style="{ color: item.color }"
            ></i>
            <div>
              <h4>{{ item.text }}</h4>
              <span>{{ item.pice | money | totalPrice }}</span>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  props: {
    info: {
      type: Array,
      default: () => []
    }
  },
  filters: {
    /* fn(str) {
      // return '￥' + str.replace(/(\d)(?=(\d{3})+\.)/g, '$1,')
      return '￥' + str
    } */
    // 过滤器,将获取的总价,使用
    totalPrice(arr) {
      return (
        // 将当前行,获取的数值,转换为字符串,使用replace方法进行正则表达过滤
        arr
          .toString()
          .replace(/(^|\s)\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
      )
    },
    // 添加羊角
    money(arr) {
      let str = ''
      str += `￥${arr}`
      return str
    }
  }
}
</script>

<style lang="less" scoped>
/deep/.el-card {
  &:hover {
    transform: scale(1.05);
  }
}
/deep/.el-col {
  padding: 0;
}
.crad {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
  i {
    display: block;
    font-size: 30px !important;
  }
}
</style>
